function drawGantt() {
	var query = new Query('ResGanttQueryHandler', 'ResGanttQueryHandler');
	query.setHandlerMethod('handler');
	if(!Ext.getCmp("startDate").getValue()||!Ext.getCmp("endDate").getValue())
	{
		Pearlsen.Utils.showInfoMsg("开始日期和结束日期必须输入");
		return;
	}
	 startDate =Ext.Date.format(Ext.getCmp("startDate").getValue(),'Y-m-d');
	 endDate =Ext.Date.format(Ext.getCmp("endDate").getValue(),'Y-m-d');
	query.addCondition("startDate", startDate);
	query.addCondition("endDate", endDate);
	query.setCompletedFun(afterloadInfo);
	query.setCompletedFunScope(drawGantt);
	query.load();
}
function afterloadInfo(success, dataset, response, opts) {
	if (success) {
		if (dataset && !Ext.isEmpty(dataset.record)) {
			var records = dataset.record;
			var dataString = '<chart manageResize="1" dateFormat="yyyy-mm-dd" outputDateFormat="yyyy-mm-dd" caption="资源申请情况" >\n\ ';
			var minDate = startDate;
			var maxDate = endDate;
			dataString+='<categories>\n\ ';
			dataString+='<category start="'+minDate+'" end="'+maxDate+'" label="日期" />\n\ ';
			dataString+='</categories>\n\ ';	
			var categories = '<categories align="left" fontSize="10">\n\ ';		
			var processes = '<processes fontSize="12" isBold="1" align="left" headerText="资源名" headerFontSize="18" headerVAlign="bottom" headerAlign="left">\n\ ';
			var tasks = '<tasks showLabels="1">\n\ ' ;
			var day = Ext.Date.getElapsed(new Date(minDate.replace(/\-/g,'/')),new Date(maxDate.replace(/\-/g,'/')))/1000/60/60/24;
			var begin = minDate;
			//设定分类
			for(var i = 0 ; i < 12;i++){
				//var x = day/20;//维度
				var end =Ext.Date.format(Ext.Date.add(new Date(begin.replace(/\-/g,'/')), Ext.Date.DAY, 15),'Y-m-d');
				categories+='<category start="'+begin+'" end="'+end+'" label="'+begin.split("-")[1]+"-"+begin.split("-")[2]+'" />\n\ ';
				begin =end;
			}
			for ( var i = 0; i < records.length; i++) {
				var r= records[i];		
				//var x = day/records.length;//维度
				//var end =Ext.Date.format(Ext.Date.add(new Date(begin.replace(/\-/g,'/')), Ext.Date.DAY, x),'Y-m-d');
				//categories+='<category start="'+begin+'" end="'+end+'" label="'+begin+'" />\n\ ';
				processes+='<process label="'+r.resName+'" id="'+r.resId+'"/>\n\ ';
				var memoryunit =r.memoryunit==0?"MB":"G";
				var storageunit =r.storageunit==0?"MB":"G";
				var label= 'cpu数:'+r.cpus +';内存:'+r.memory+memoryunit+';硬盘:'+r.storage+storageunit+';网卡数:'+r.netcards;
				tasks+='<task processId="'+r.resId+'" start="'+r.startDate+'" end="'+r.endDate+'" label="'+label+'"/>\n\ ';		
				//begin =end;
			}
			categories+='</categories>\n\ ';
			processes+='</processes>\n\ ';
			tasks+='</tasks>\n\ ';
			dataString+=categories;
			dataString+=processes;
			dataString+=tasks;
			dataString+='</chart>';
			chart.setXMLData(dataString);
			chart.render("chartdiv");
			//alert(dataString);
		} else {
			Ext.Msg.alert("提示", "服务器空闲，暂无监控数据");
		}
	} else {
		Ext.Msg.alert("提示", "查询不到监控数据");
	}
}
